<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*" %>
<%@ page import="dto.*" %>


<html>
<head>
<link rel="stylesheet" href="css/estilo.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Generar Comanda</title>
<script type="text/javascript" language="JavaScript">

function valideDatos() {
	var cantidad = document.getElementById("numeroMesa");
	
	if((cantidad.value == "" || cantidad.value == '' || cantidad.value == null)
			|| cantidad.value==" ") {
		alert("Ingrese el numero de mesa");
		return false;
	
	} else  {
		return true;
	}
}

function justNumbers(e)
{
var keynum = window.event ? window.event.keyCode : e.which;
if ((keynum == 8) || (keynum == 46))
return true;
 
return /\d/.test(String.fromCharCode(keynum));
}


</script>
</head>
<body>

<%String flag=(String)request.getAttribute("flag");

if(flag!=null){
	
	%>
	<script type="text/javascript">alert('<%=flag%>');</script>
<%}%>


<h1>GENERAR COMANDA</h1>
<form action="GenerarComandaFinalServlet" method="POST" onsubmit="return valideDatos();">

<table cellspacing="3" cellpadding="3" border="1" width="500">
	
		
	
	<%
		
		SucursalDTO suc=(SucursalDTO)request.getSession().getAttribute("sucursal");
		for(CartaDTO carta:suc.getCartas()){
			%><tr>
		<td><%=carta.getNombre() %> </td>
			
	</tr>
	<% 
		
		for(RubroDTO rubro:carta.getRubros())
		{
			%>
			<tr>
			<td>Rubro:     <%=rubro.getNombre() %></td> 
			<td><p>
			Plato
			</p></td>
			</tr>
			
		
		<%
		
		List<PlatoDTO> platos=rubro.getPlatos();
		for(Iterator<PlatoDTO> i=platos.iterator();i.hasNext();)
		{
			PlatoDTO plato=i.next();
			Integer id=plato.getId();
		%>
	
		<tr>
			<td>
			<input type="button" value="AgregarCantidad" onClick="location.href='GenerarComandaServlet?action=Agregar&id=<%=id%>'">
			</td>
			<td><%= plato.getNombre() %> </td>
			
			
			
		</tr>
	
		
		
			
			<%} }}%>
			
			<tr>
		<td>Numero de mesa</td>
		<td><input type="text" name="numeroMesa" id="numeroMesa" onkeypress="return justNumbers(event);"></td>
	</tr>
			
	<tr>
		<td><input type="button" value="Cancelar" style="font-size: 14px" onclick="window.location.href='index.jsp'"> </td>
		<td><input type="submit" value="GenerarComanda" style="font-size: 14px"> </td>
		
	
	</tr>
	
</table>
</form>

</body>
</html>